package com.shuwen.gcdj.controller.statistics;

import com.shuwen.gcdj.bean.workingConditions.request.StatisticConditionReq;
import com.shuwen.gcdj.bean.workingConditions.response.*;
import com.shuwen.gcdj.common.annotation.JWTAuth;
import com.shuwen.gcdj.common.api.CommonResult;
import com.shuwen.gcdj.controller.AuthController;
import com.shuwen.gcdj.service.statistic.WorkingConditionsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

/**
 * 工况统计
 * @author XYC
 */
@Api(tags = "工况统计")
@RestController
@RequestMapping("/workingConditions")
@Slf4j
public class WorkingConditionsController extends AuthController {

    @Autowired
    private WorkingConditionsService workingConditionsService;


    @ApiOperation(value = "设备状态信息")
    @PostMapping(value = "/getDeviceStatusAsync")
    @JWTAuth
    public CommonResult<StatisticsDeviceStatusDataResp> getDeviceStatusAsync(@RequestBody @Valid StatisticConditionReq req, BindingResult bindingResult){

        return  workingConditionsService.getDeviceStatusAsync(req);
    };


    @ApiOperation(value = "累计数据")
    @PostMapping(value = "/getStatisticsOperatingmodeloadAsync")
    @JWTAuth
    public CommonResult<List<StatisticsPlcCumulativeDataResp>> getStatisticsOperatingmodeloadAsync( @RequestBody @Valid StatisticConditionReq req, BindingResult bindingResult){

        return  workingConditionsService.getStatisticsOperatingmodeloadAsync(req);
    };

    @ApiOperation(value = "Plc实时数据")
    @PostMapping(value = "/getStatisticsOperatingmodeloadRealtime")
    @JWTAuth
    public CommonResult<List<StatisticsRealtimePlcResp>> getStatisticsOperatingmodeloadRealtime(@RequestBody @Valid StatisticConditionReq req, BindingResult bindingResult){

        return workingConditionsService.getStatisticsOperatingmodeloadRealtime(req);
    };

    @ApiOperation(value = "热力图")
    @PostMapping(value = "/getListOperatingmodeoperationAsync")
    @JWTAuth
    public CommonResult<StatisticsThermalMapResp> getListOperatingmodeoperationAsync(@RequestBody @Valid StatisticConditionReq req,BindingResult bindingResult){

        return workingConditionsService.getListOperatingmodeoperationAsync(req);
    };
}
